<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    const obj = {
    count: 1
}
const getDouble = v => v*2
let double = getDouble(obj.count)
const proxy = new Proxy(obj, {
    get(target, prop) {
        return target[prop]
    },
    set(target, prop, value) {
        console.log('set===', target, prop, value)
        target[prop] = value
        // console.log('set===', target, prop, value)
        if (prop === 'count') {
            double = getDouble(value)
        }
    },
    deleteProperty(target, prop) {
        delete target[prop]
        if (prop === 'count') {
            double = NaN
        }
    }
})
console.log('count', obj.count)
console.log('double', double)
console.log('count + 1之后====')
proxy.count = 2
console.log('count', obj.count)
console.log('double', double)
delete proxy.count
console.log('删除count之后====')
console.log('count', obj.count)
console.log('double', double)
</script>
</html>